﻿using System.Data;
using System.Data.Entity.Infrastructure;
using Quba.DataAccess.Repositories.Abstract;
using Quba.Entities.Database.Tag;

namespace Quba.DataAccess.Repositories.Concrete
{
    public class TagRepository : QubaBaseRepositoty<Tag>, ITagRepository
    {
        private Tag _result;

        #region Get
        public override Tag Get(int tagId)
        {
            return _GetQubaContext().Tags.Find(tagId);
        }
        #endregion Get

        #region Update
        public override Tag Update(Tag tag)
        {
            _result = _GetQubaContext().Tags.Add(tag);
            DbEntityEntry entry = _GetQubaContext().Entry(tag);
            entry.State = EntityState.Modified;

            _GetQubaContext().SaveChanges();
            return _result;
        }
        #endregion Update
    }
}